<?php
namespace tq;
/**
* 
*/
class Tq
{
    
    public static function get($city)
    {
        $host = "http://jisutqybmf.market.alicloudapi.com";
        $path = "/weather/query";
        $method = "GET";
        $appcode = "ab7bfa4f7d544241998ea5d8a8ddb028";
        $headers = array();
        array_push($headers, "Authorization:APPCODE " . $appcode);
        $querys = "city=".$city;
        $bodys = "";
        $url = $host . $path . "?" . $querys;

        $curl = curl_init();
        curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($curl, CURLOPT_FAILONERROR, false);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_HEADER, false);
        if (1 == strpos("$".$host, "https://"))
        {
            curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
        }
        $data = (curl_exec($curl));

        return json_decode($data,true);
    }
}